import { http } from '@/utils/http'

export type ApiParamBo = {
  paramName: string
  paramCatalog: string
  paramPosition: string
  paramType: string
  required: boolean
  paramDesc: string
  exampleValue: string
}

export type ApiResponseBo = {
  paramName: string
  paramType: string
  paramDesc: string
}

export type ApiErrorCodeBo = {
  errorCode: string
  errorInfo: string
  errorDesc: string
}

export type FormData = {
  /** 算法基础 */
  algorithmBasic: string[]
  apiAuth: string
  apiCatalog: string
  apiDesc: string
  apiErrorCodeBoList: ApiErrorCodeBo[]
  apiIconPth: string
  apiIntro: string
  apiName: string
  apiParamList: ApiParamBo[]
  apiResponseList: ApiResponseBo[]
  apiType: string
  checkStatus: string
  encryptionType: string[]
  ossId: string
  requestMethod: string
  requestPath: string
  requestProtocol: string
  requestTimeOut: number
  responseExampleValue: string
  responseFailValue: string
  responseType: string
  serverContentType: string
  serverNetworkType: string
  serverProdPath: string
  serverTestPath: string
  serverUri: string
  /** 算法版本 */
  version: string
}

// 新增
export const add = (data?: object) => {
  return http.request('post', '/manage/apiInfo/apiInfo', { data })
}
// 修改
export const modify = (data?: object) => {
  return http.request('put', '/manage/apiInfo/apiInfo', { data })
}
// 编辑
export const costMgtUpdate = (data?: object) => {
  return http.request('post', '/app/update', { data })
}

// 列表
export const getList = (params?: object) => {
  return http.request('get', '/manage/approve/approves', { params })
}
// 详情信息
export const getDetail = (params?: number) => {
  return http.request('get', '/manage/approve/apiApplyInfo', {
    params: { applyId: params },
  })
}
// 删除
export const deleteApp = (params?: object) => {
  return http.request('delete', `/app/${params}`)
}
// 接口审批
export const approve = (params?: object) => {
  return http.request('put', '/manage/approve/approve', { params })
}
